/*
 * Vertex.h
 *
 *  Created on: May 26, 2012
 *      Author: marchi
 */

#ifndef VERTEX_H_
#define VERTEX_H_
#include <iostream>
#include <iomanip>
#include <ostream>
#include <vector>
#include <algorithm>
using std::vector;
using std::cout;
using std::endl;
using std::sort;

class Vertex {
	vector<int> ver;
	void ccopy(const Vertex & y){
		ver=y.ver;
	}
	void indcopy(const vector<int> & z){
		for(unsigned int n=0;n<ver.size();n++)
			ver[n]=z[ver[n]];
	}
	inline bool minus(const Vertex & y, unsigned int & n) const{
		if(n==ver.size())return false;
		return (ver[n] < y.ver[n])?true:(ver[n]==y.ver[n])?minus(y,++n):false;
	}
	inline bool greater(const Vertex & y, unsigned int & n)const {
		if(n==ver.size())return false;
		return (ver[n] > y.ver[n])?true:(ver[n]==y.ver[n])?greater(y,++n):false;
	}
public:
	Vertex(){};
	Vertex(vector<int> & y){
		sort(y.begin(),y.end());
		ver=y;
	}
	Vertex(Vertex & x, const vector<int> & z){
		*this=x;
		indcopy(z);
	}
	Vertex & operator()(const Vertex & y){ccopy(y); return *this;};
	bool operator<(const Vertex & y) const {
		unsigned int n=0;
		return minus(y,n);
	}
	bool operator>(const Vertex & y) const {
		unsigned int n=0;
		return greater(y,n);
	}
	vector<int> gnoVertex() const {return ver;}

	virtual ~Vertex();
	friend std::ostream & operator<<(std::ostream & fout, const Vertex & y ){
		for(unsigned int n=0;n<y.ver.size();n++)
			fout << std::fixed << std::setw(6)<< std::right << y.ver[n] << " ";
		return fout;
	}
};

#endif /* VERTEX_H_ */
